//
//  ViewController.m
//  DemoFunctionView
//
//  Created by 唐可雄 on 16/6/21.
//  Copyright © 2016年 swustyc. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<YCFunctionViewDataSource, YCFunctionViewDelegate> {
    NSArray *_array;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    _array = @[@{@"img":@"function1",
                 @"title":@"QQ",
                 @"badge":@"1"},
               @{@"img":@"function2",
                 @"title":@"微博",
                 @"badge":@"1"},
               @{@"img":@"function3",
                 @"title":@"QQ",
                 @"badge":@"1"},
               @{@"img":@"function4",
                 @"title":@"哇哇",
                 @"badge":@"1"},
               @{@"img":@"function5",
                 @"title":@"提提",
                 @"badge":@"1"},
               @{@"img":@"function6",
                 @"title":@"送上哦",
                 @"badge":@"1"},
               @{@"img":@"function2",
                 @"title":@"伟大了",
                 @"badge":@"1"},
               @{@"img":@"function3",
                 @"title":@"找地方",
                 @"badge":@"1"},
               @{@"img":@"function4",
                 @"title":@"开房间",
                 @"badge":@"1"},
               @{@"img":@"function5",
                 @"title":@"笑哈哈",
                 @"badge":@"1"},
               @{@"img":@"function6",
                 @"title":@"搜索",
                 @"badge":@"1"}];
    
    self.functionView.dataSource = self;
    self.functionView.delegate = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfCellsInFunctionView:(YCFunctionView *)functionView {
    return _array.count;
}

- (CGSize)sizeOfCellInFunctionView:(YCFunctionView *)functionView {
    return CGSizeMake(60, 80);
}

- (void)functionView:(YCFunctionView *)functionView configCell:(YCFunctionViewCell *)cell atIndex:(NSInteger)index {
    [cell.imgView setImage:[UIImage imageNamed:_array[index][@"img"]]];
    cell.titleLabel.text = _array[index][@"title"];
    cell.badgeLabel.text = _array[index][@"badge"];
}

@end
